home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-30 | 4.0 KB | 97 lines | [TEXT/R*ch] |
- 3D-Viewer
- ---------
-
- 3D-Viewer is an example of a basic 3D graphics app in REALbasic. It
- will render shaded 3D models composed of opaque colored polygonal faces
- in real time.
-
- The program is not particularly sophisticated or fast, but it should be
- useful as an example for people interested in dabbling in 3D graphics
- programmng. There's no facility yet for creating or editing models,
- but you can edit the face colors of existing models and save the
- modified models to disk. A number of models are distributed with the
- project; these are all taken from the GeomView distribution (see below).
-
-
- History
- -------
-
- 3D-Viewer started out as a pretty straight port of a GPL'd Java applet
- ("Viewer3D") written by Daeron Meyer of the Geometry Center at the
- University of Minnesota. The applet lets people view 3D objects
- described in OOGL-OFF files. [OOGL is the Geometry Center's "Object-
- Oriented Graphics Language" and OFF ("Object File Format") is one file
- format supported by the OOGL.]
-
- The Geometry Center is unfortunately defunct but there are still a number of
- interesting things available from their homepage, at <http://www.geom.umn.edu/>.
- Among these is their 3D modelling package, GeomView, which is distributed
- with the complete Unix source code.
-
-
- The Code
- --------
-
- There are two key classes, Viewer3D and OOGL_OFF.
-
- Viewer3D is a Canvas subclass. It interactively displays the image
- produced by an object that implements the ViewableObject interface.
- Viewer3D sets the scaling so that the image fits on the display, and
- updates a rotation matrix for the object when the user drags the mouse
- on the canvas; the object is rescaled if the Option key is help down
- while dragging. Viewer3D double-buffers the display so that updates are
- smooth, but calls the Paint method of the ViewableObject to actually
- render the model. The Viewer3D class also allows object selection, but
-
-
- OOGL_OFF is the class that describes the 3D object; it implements the
- ViewableObject interface. It maintains a display list of 3D vertices
- and colored polygonal faces defined using those vertices. It can read
- descriptions of models from OFF-format files on the disk. It has a
- Paint method that will render the model into a Graphics object.
- Rendering is done using the Painter's method: faces are sorted in
- z-order and drawn from back to front. No effort is made to deal with
- interections of polygons. Shading is handled by the simple lighting
- model described at <http://exaflop.org/docs/lca/lca1.html>. Selection
- of faces is based on the point-in-polygon algorithm presented in the
- comp.graphics.algorithms FAQ <http://exaflop.org/docs/cgafaq/>.
-
-
- There are a couple of helper classes that may be useful in other contexts:
-
- Matrix3D is a standard 4x4 transformation matrix. It is derived from
- the Matrix3D class used in the Sun's demo Java applets.
-
- StreamTokenizer is a straight port of the standard Java StreamTokenizer
- class, which parse text streams into tokens. It has been modified to
- accept either a String or a TextInputStream for processing. It's used
- here by the OOGL_OFF class for parsing OFF files.
-
- Credits
- -------
-
- The final form of 3DViewer owes a lot to Geoff Perlman's many insistent
- suggestions.
-
- The original Java version of the OOGL_OFF class is ⌐ Daeron Mayer and
- was released under the Gnu Public License. Besides porting it to
- REALbasic, I also added methods to interactively pick faces and to
- render models with shading.
-
- Except for Daeron Mayer's OOGL_OFF class, most of the original Java code
- is ⌐ Sun Microsystems, Inc.
-
- The mCanvasButton class was written by S┐ren Olin. It's available from
- <http://www.olin.net/RB/>. You'd think an image button would be easy to
- create, but the other ones I tried all had strange quirks; this one
- works well.
-
-
- March 1999
-
- -------------------------------------------------------------------------
- W. Thomas Pollard Schrodinger, Inc.
- pollard@schrodinger.com http://www.schrodinger.com/
- -------------------------------------------------------------------------
-
-